﻿using DLL.MSDM.Entity.Param;
using DLL.NET70.Infrastructure.Prism.MVVM;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Module.MSDMMotionShell.ViewModels
{
    public class PUC_MSDMHomeShellViewModel : CMVVMBase, IRegionMemberLifetime
    {
        public bool KeepAlive
        {
            get
            {
                //return false;//这个的作用是，只要离开当前切面，就注销掉当前页面
                return false;//这个的作用是，只要离开当前切面，就注销掉当前页面
            }
        }

        public PUC_MSDMHomeShellViewModel(IRegionManager regionManager, IEventAggregator eventAggregator) : base(regionManager, eventAggregator)
        {
        }

        public override void Loaded()
        {
            CWR_MotionCardType wrcard = new CWR_MotionCardType();
            CMotionCardType card = new CMotionCardType();
            wrcard.ReadParam();
            card = wrcard.Obj;
            if (card != null)
            {
                if (card.DeviceType == 0)
                {
                    //6工位配药机
                    Navigate("MSDMHomeShellRegion", "PUC_9Home");
                }
                else
                {
                    //4工位配药机
                    Navigate("MSDMHomeShellRegion", "PUC_6Home");
                }
            }
            base.Loaded();
        }

        private void Navigate(string region, string navigatePath)
        {
            if (navigatePath != null)
            {
                RegionManager.RequestNavigate(region, navigatePath);
            }
        }
    }
}